<?php $this->load->view('includes/head.php'); ?>



<div class="container">
  <div class="row">


    <div class="col-sm-12">
	<h3>Edit Tasks   <small><a href="<?php echo site_url('/manage/add-new-task'); ?>">Create Task</a></small></h3>
	<hr>
      <table class="table table-hover">
      <thead>
        <tr>
          <th>#</th>
          <th>Task</th>
          <th>Date Created</th>
          <th>Due Date</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
        <?php 
        $count = 0;
        foreach ($tasks as $task) {
          $title = $task->title;
          $view_task_url = site_url('tasks/'.$task->url);
          $delete_task_url = site_url('tasks/delete/'.$task->url);
          $edit_task_url = site_url('tasks/edit/'.$task->url);
          $content = $task->content;
          $count++;
          date_default_timezone_set('GMT');
          $due_date = mdate('%M %d, %Y',strtotime($task->date_due));
          $date_created = mdate('%M %d, %Y',strtotime($task->date_created));
          $action;
          if ($userid == $task->user_id) {
            $action = '<li><a href="'.$delete_task_url.'" rel="tooltip" class="btn btn-danger btn-xs" data-toggle="tooltip" data-placement="right" title="Delete Task"><i class="fa fa-times"></i></a></li>';
          }else{
            $action = '';
          }
          echo<<<EOT
          <tr>
            <td>$count</td>
            <td class="edit-row"><strong class="table-title text-warning">$title</strong></td>
            <td>$date_created</td>
            <td>$due_date</td>
            <td>
            	<div class="btn-group">
               <ul class="list-inline">
                <li>
                  <a href="$view_task_url" rel="tooltip" class="btn btn-primary btn-xs" data-toggle="tooltip" data-placement="left" title="View Task"><i class="fa fa-eye"></i></a>
                </li>
                <li>
                  <a href="$edit_task_url" rel="tooltip" class="btn btn-success btn-xs" data-toggle="tooltip" data-placement="top" title="Edit Task"><i class="fa fa-pencil"></i></a>
                </li>
                $action
                </ul>
			        </div>
            </td>
          </tr>
EOT;
        }
      ?>
      </tbody>
    </table>
    </div>
			        <!-- <button type="button" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i></button> -->


  </div>
</div>